import random

def cmp(a,b):
    if int(a.num)<int(b.num):
        return -1
    else:
        return 1

def randInList(list):
    l = len(list) - 1
    return list[random.randint(0,l)]

def randInListNot(list1,list2):
    l = len(list1) - 1
    while True:
        r=list1[random.randint(0, l)]
        if not r in list2:
            break
    return r

def nameToObj(name,allStudent):
    for s in allStudent:
        if s.name==name:
            return s

def touzi():
    return random.randint(0,1)==1

def writeFile(filePath, content):
    print('Write info to file:Start...')
    # 将文件内容写到文件中
    with open(filePath, 'a', encoding='utf-8') as f:
        f.write(content)
        print('Write info to file:end...')

def readFile(filepath):
    f=open(filepath,'r')
    return f.read()